#ifndef FASTNETDEVICE_HH_
#define FASTNETDEVICE_HH_

#include <list>

#include <sys/select.h>
#include <sys/time.h>
#include <sys/types.h>
#include <sys/file.h>
#include <sys/socket.h>
#include <arpa/inet.h>

#include <netinet/in.h>

#include <errno.h>

#include <iostream>
#include <lagniappe/RequestDevice.h>
#include <lagniappe/RCon.h>
#include <lagniappe/RData.h>

#include "FastNetDeviceThread.hh"

#include "NetRequest.hh"
#include "Synchronized.hh"

class FastNetDeviceThread;

extern int errno;

const uint32_t BUFSIZE = 8192;
const uint32_t LAGNIAPPE_PORT = 7775;
const int NUM_THREADS = 4;

namespace requestDevices
{

class FastNetDevice : public lagniappe::RequestDevice, Synchronized
{
	fd_set openSet;
	socket_t maxFD;
	socket_t i;
	socket_t listener;
	std::list<FastNetDeviceThread *> threadList;
	std::string intfName;
	bool sysReady;
public:
	FastNetDevice(std::string intf);
	virtual ~FastNetDevice();
	virtual void run(lagniappe::RCon * rcon);
	virtual void start();
	socket_t getActiveSocket();
	void clearSock(socket_t clear) {Synchronized::Scope mutex(this); FD_CLR(clear, &openSet);}
	std::pair<lagniappe::CoreOp *, std::string> * getDest() {return destMap["out"];}
	
	
};

}

#endif /*FASTNETDEVICE_HH_*/
